home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / rain_for.swf / scripts / __Packages / Player.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  22.6 KB  |  859 lines

  1. class Player extends smashing.Renderable
  2. {
  3.    var update;
  4.    var halfR;
  5.    var fruitSounds;
  6.    var hangSounds;
  7.    var pointSounds;
  8.    var oGerms;
  9.    var tempM;
  10.    var x;
  11.    var y;
  12.    var cHurt;
  13.    var a;
  14.    var oSwing;
  15.    var lastPos;
  16.    var lastElapsed;
  17.    var oCitizens;
  18.    var shadow;
  19.    var oBuildings;
  20.    var nStartHurt;
  21.    var onEnterFrame;
  22.    var mcInvul;
  23.    var aCritters;
  24.    var camera;
  25.    var oWorld;
  26.    var upThrust = 1700;
  27.    var sideThrust = 300;
  28.    var r = 50;
  29.    var xm = 0;
  30.    var ym = 0;
  31.    var jumpm = 0;
  32.    var ySpeedLimit = 500;
  33.    var onSurface = false;
  34.    var nHurtFlash = 0.1;
  35.    var nHurtTime = 2;
  36.    var bHurt = false;
  37.    var cGerms = 0;
  38.    var facing = 1;
  39.    var floorMod = 50;
  40.    var germScore = 5;
  41.    var nInvul = 5;
  42.    var cInvul = 0;
  43.    var bInvul = false;
  44.    var nSpeed = 0;
  45.    var nSpeedBoost = 150;
  46.    var nSpeedTime = 5;
  47.    var cSpeedTime = 0;
  48.    var nHang = 10;
  49.    var cHang = 0;
  50.    var nCrouchMod = 0;
  51.    var nIdle = 10;
  52.    var cIdle = 0;
  53.    var sIdle = "";
  54.    var bSpaceDown = false;
  55.    function Player()
  56.    {
  57.       super();
  58.       this.update = this.updatePrompt;
  59.       this.floorMod += this.r;
  60.       this.halfR = this.r / 2;
  61.       this.cGerms = 0;
  62.       this.fruitSounds = ["las_fruitas","fruitas","fruit"];
  63.       this.hangSounds = ["its_rescue_pack","wheee","were_flying"];
  64.       this.pointSounds = ["bonus_points","bonus"];
  65.    }
  66.    function get germs()
  67.    {
  68.       return this.cGerms;
  69.    }
  70.    function updateGround(nElapsed)
  71.    {
  72.       var _loc8_ = undefined;
  73.       var _loc4_ = "stand";
  74.       var _loc10_ = false;
  75.       if(this.nSpeed == 1)
  76.       {
  77.          this.cSpeedTime += nElapsed;
  78.          _loc8_ = 0;
  79.          if(Key.isDown(39))
  80.          {
  81.             _loc8_ += nElapsed * (this.sideThrust + this.nSpeedBoost);
  82.             this.faceRight();
  83.             _loc4_ = "run";
  84.          }
  85.          if(Key.isDown(37))
  86.          {
  87.             _loc8_ -= nElapsed * (this.sideThrust + this.nSpeedBoost);
  88.             this.faceLeft();
  89.             _loc4_ = "run";
  90.          }
  91.          if(this.cSpeedTime >= this.nSpeedTime)
  92.          {
  93.             this.unSpeed();
  94.          }
  95.       }
  96.       else
  97.       {
  98.          _loc8_ = 0;
  99.          if(Key.isDown(39))
  100.          {
  101.             _loc8_ += nElapsed * this.sideThrust;
  102.             this.faceRight();
  103.             _loc4_ = "run";
  104.          }
  105.          if(Key.isDown(37))
  106.          {
  107.             _loc8_ -= nElapsed * this.sideThrust;
  108.             this.faceLeft();
  109.             _loc4_ = "run";
  110.          }
  111.       }
  112.       if(Key.isDown(38) || Key.isDown(32))
  113.       {
  114.          if(this.onSurface == true)
  115.          {
  116.             this.jumpm -= this.upThrust;
  117.          }
  118.          if(this.jumpm < 0)
  119.          {
  120.             this.jumpm += smashing.Phys.gr * nElapsed;
  121.          }
  122.          else
  123.          {
  124.             this.jumpm = 0;
  125.             this.ym += smashing.Phys.gr * nElapsed;
  126.          }
  127.          this.bSpaceDown = true;
  128.       }
  129.       else
  130.       {
  131.          this.jumpm = 0;
  132.          this.ym += smashing.Phys.gr * nElapsed;
  133.          this.bSpaceDown = false;
  134.       }
  135.       if(Key.isDown(40))
  136.       {
  137.          this.onSurface = false;
  138.          _loc10_ = true;
  139.       }
  140.       if(Math.abs(this.jumpm) > this.ySpeedLimit)
  141.       {
  142.          this.jumpm = this.ySpeedLimit * (this.jumpm / Math.abs(this.jumpm));
  143.       }
  144.       var _loc5_ = this.oGerms.oHandler.clips;
  145.       var _loc7_ = _loc5_.length;
  146.       var _loc2_ = undefined;
  147.       var _loc15_ = undefined;
  148.       var _loc14_ = new smashing.Point(0,0);
  149.       var _loc3_ = 0;
  150.       while(_loc3_ < _loc7_)
  151.       {
  152.          _loc2_ = _loc5_[_loc3_];
  153.          if(_loc2_ != null)
  154.          {
  155.             if(_loc2_.grabbable == true)
  156.             {
  157.                if(_loc2_.checkHit(this))
  158.                {
  159.                   _loc2_.react(this);
  160.                }
  161.             }
  162.          }
  163.          _loc3_ = _loc3_ + 1;
  164.       }
  165.       if(m.y > this.halfR)
  166.       {
  167.          m.y = this.halfR;
  168.       }
  169.       this.tempM = null;
  170.       var _loc11_ = this.checkCollisions(nElapsed,_loc8_,_loc10_,false);
  171.       var m = this.tempM;
  172.       var _loc13_ = new smashing.Point(this.x,this.y);
  173.       var _loc12_ = BuildingHandler.floor - this.floorMod;
  174.       if(this.y + m.y > _loc12_)
  175.       {
  176.          this.y = _loc12_;
  177.          this.ym = 0;
  178.          this.jumpm = 0;
  179.          m.y = 0;
  180.          this.onSurface = true;
  181.          _loc11_ = true;
  182.          if(_loc10_ == true)
  183.          {
  184.             _loc4_ = "crouch";
  185.          }
  186.       }
  187.       if(_loc11_ == false)
  188.       {
  189.          if(this.ym > 0)
  190.          {
  191.             _loc4_ = "jumpDown";
  192.          }
  193.          else
  194.          {
  195.             _loc4_ = "jumpUp";
  196.          }
  197.       }
  198.       var _loc9_ = smashing.Viewport.halfWidth - this.r;
  199.       if(this.x + m.x - smashing.Viewport.x < - _loc9_)
  200.       {
  201.          this.x = smashing.Viewport.x - _loc9_;
  202.          m.x = 0;
  203.          this.xm = 0;
  204.       }
  205.       if(this.x + m.x - smashing.Viewport.x > _loc9_)
  206.       {
  207.          this.x = smashing.Viewport.x + _loc9_;
  208.          m.x = 0;
  209.          this.xm = 0;
  210.       }
  211.       this.y += m.y;
  212.       this.x += m.x;
  213.       if(this.bHurt == true)
  214.       {
  215.          if(this.cHurt < this.nHurtTime / 2)
  216.          {
  217.             _loc4_ = "hit";
  218.          }
  219.       }
  220.       this.a.gotoAndStop(_loc4_);
  221.       if(this.nSpeed == 1)
  222.       {
  223.          this.a.blur._visible = true;
  224.       }
  225.       else
  226.       {
  227.          this.a.blur._visible = false;
  228.       }
  229.    }
  230.    function updateHangPre(nElapsed)
  231.    {
  232.       this.a.gotoAndStop("hangStart");
  233.    }
  234.    function updateHang(nElapsed)
  235.    {
  236.       var _loc8_ = undefined;
  237.       var _loc10_ = false;
  238.       if(this.nSpeed == 1)
  239.       {
  240.          this.cSpeedTime += nElapsed;
  241.          _loc8_ = 0;
  242.          if(Key.isDown(39))
  243.          {
  244.             _loc8_ += nElapsed * (this.sideThrust + this.nSpeedBoost);
  245.             this.faceRight();
  246.          }
  247.          if(Key.isDown(37))
  248.          {
  249.             _loc8_ -= nElapsed * (this.sideThrust + this.nSpeedBoost);
  250.             this.faceLeft();
  251.          }
  252.          if(this.cSpeedTime >= this.nSpeedTime)
  253.          {
  254.             this.unSpeed();
  255.          }
  256.       }
  257.       else
  258.       {
  259.          _loc8_ = 0;
  260.          if(Key.isDown(39))
  261.          {
  262.             _loc8_ += nElapsed * this.sideThrust;
  263.             this.faceRight();
  264.          }
  265.          if(Key.isDown(37))
  266.          {
  267.             _loc8_ -= nElapsed * this.sideThrust;
  268.             this.faceLeft();
  269.          }
  270.       }
  271.       if(Key.isDown(38) || Key.isDown(32))
  272.       {
  273.          this.ym -= this.upThrust * nElapsed;
  274.          this.onSurface = false;
  275.       }
  276.       if(Key.isDown(40))
  277.       {
  278.          this.ym += this.upThrust * nElapsed;
  279.          this.onSurface = false;
  280.          _loc10_ = true;
  281.       }
  282.       this.ym += (smashing.Phys.gr - 200) * nElapsed;
  283.       if(Math.abs(this.ym) > this.ySpeedLimit)
  284.       {
  285.          this.ym = this.ySpeedLimit * (this.ym / Math.abs(this.ym));
  286.       }
  287.       var _loc6_ = this.oGerms.oHandler.clips;
  288.       var _loc7_ = _loc6_.length;
  289.       var _loc2_ = undefined;
  290.       var _loc16_ = undefined;
  291.       var _loc15_ = new smashing.Point(0,0);
  292.       var _loc3_ = 0;
  293.       while(_loc3_ < _loc7_)
  294.       {
  295.          _loc2_ = _loc6_[_loc3_];
  296.          if(_loc2_ != null)
  297.          {
  298.             if(_loc2_.grabbable == true)
  299.             {
  300.                if(_loc2_.pCurrLength == undefined)
  301.                {
  302.                   if(_loc2_.checkHit(this))
  303.                   {
  304.                      _loc2_.react(this);
  305.                   }
  306.                }
  307.             }
  308.          }
  309.          _loc3_ = _loc3_ + 1;
  310.       }
  311.       this.tempM = null;
  312.       var _loc13_ = this.checkCollisions(nElapsed,_loc8_,_loc10_,true);
  313.       var _loc4_ = this.tempM;
  314.       var _loc14_ = new smashing.Point(this.x,this.y);
  315.       var _loc12_ = BuildingHandler.floor - this.floorMod;
  316.       if(this.y + _loc4_.y > _loc12_)
  317.       {
  318.          this.y = _loc12_;
  319.          this.ym = 0;
  320.          this.jumpm = 0;
  321.          _loc4_.y = 0;
  322.          this.onSurface = true;
  323.          _loc13_ = true;
  324.       }
  325.       var _loc11_ = BuildingHandler.ceiling + this.r;
  326.       if(this.y + _loc4_.y < _loc11_)
  327.       {
  328.          this.ym = 0;
  329.          this.jumpm = 0;
  330.          _loc4_.y = 0;
  331.          this.y = _loc11_;
  332.       }
  333.       var _loc9_ = smashing.Viewport.halfWidth - this.r;
  334.       if(this.x + _loc4_.x - smashing.Viewport.x < - _loc9_)
  335.       {
  336.          this.x = smashing.Viewport.x - _loc9_;
  337.          _loc4_.x = 0;
  338.          this.xm = 0;
  339.       }
  340.       if(this.x + _loc4_.x - smashing.Viewport.x > _loc9_)
  341.       {
  342.          this.x = smashing.Viewport.x + _loc9_;
  343.          _loc4_.x = 0;
  344.          this.xm = 0;
  345.       }
  346.       this.y += _loc4_.y;
  347.       this.x += _loc4_.x;
  348.       if(this.bHurt == true)
  349.       {
  350.          if(this.cHurt < this.nHurtTime / 2)
  351.          {
  352.          }
  353.       }
  354.       this.a.gotoAndStop("hang");
  355.       if(this.nSpeed == 1)
  356.       {
  357.          this.a.blur._visible = true;
  358.       }
  359.       else
  360.       {
  361.          this.a.blur._visible = false;
  362.       }
  363.       this.cHang += nElapsed;
  364.       if(this.cHang >= this.nHang)
  365.       {
  366.          this.unHang();
  367.       }
  368.    }
  369.    function updatePrompt(nElapsed)
  370.    {
  371.       var _loc10_ = undefined;
  372.       var _loc6_ = "stand";
  373.       var _loc12_ = false;
  374.       if(this.nSpeed == 1)
  375.       {
  376.          this.cSpeedTime += nElapsed;
  377.          _loc10_ = 0;
  378.          if(Key.isDown(39))
  379.          {
  380.             _loc10_ += nElapsed * (this.sideThrust + this.nSpeedBoost);
  381.             this.faceRight();
  382.             _loc6_ = "run";
  383.             this.update = this.updateGround;
  384.          }
  385.          if(Key.isDown(37))
  386.          {
  387.             _loc10_ -= nElapsed * (this.sideThrust + this.nSpeedBoost);
  388.             this.faceLeft();
  389.             _loc6_ = "run";
  390.             this.update = this.updateGround;
  391.          }
  392.          if(this.cSpeedTime >= this.nSpeedTime)
  393.          {
  394.             this.unSpeed();
  395.          }
  396.       }
  397.       else
  398.       {
  399.          _loc10_ = 0;
  400.          if(Key.isDown(39))
  401.          {
  402.             _loc10_ += nElapsed * this.sideThrust;
  403.             this.faceRight();
  404.             _loc6_ = "run";
  405.             this.update = this.updateGround;
  406.          }
  407.          if(Key.isDown(37))
  408.          {
  409.             _loc10_ -= nElapsed * this.sideThrust;
  410.             this.faceLeft();
  411.             _loc6_ = "run";
  412.             this.update = this.updateGround;
  413.          }
  414.       }
  415.       if(Key.isDown(38) || Key.isDown(32))
  416.       {
  417.          if(this.onSurface == true)
  418.          {
  419.             this.jumpm -= this.upThrust;
  420.          }
  421.          if(this.jumpm < 0)
  422.          {
  423.             this.jumpm += smashing.Phys.gr * nElapsed;
  424.          }
  425.          else
  426.          {
  427.             this.jumpm = 0;
  428.             this.ym += smashing.Phys.gr * nElapsed;
  429.          }
  430.          this.bSpaceDown = true;
  431.          this.update = this.updateGround;
  432.       }
  433.       else
  434.       {
  435.          this.jumpm = 0;
  436.          this.ym += smashing.Phys.gr * nElapsed;
  437.          this.bSpaceDown = false;
  438.       }
  439.       if(Key.isDown(40))
  440.       {
  441.          this.onSurface = false;
  442.          _loc12_ = true;
  443.          this.update = this.updateGround;
  444.       }
  445.       if(Math.abs(this.jumpm) > this.ySpeedLimit)
  446.       {
  447.          this.jumpm = this.ySpeedLimit * (this.jumpm / Math.abs(this.jumpm));
  448.       }
  449.       var _loc8_ = this.oGerms.oHandler.clips;
  450.       var _loc9_ = _loc8_.length;
  451.       var _loc4_ = undefined;
  452.       var _loc17_ = undefined;
  453.       var _loc16_ = new smashing.Point(0,0);
  454.       var _loc5_ = 0;
  455.       while(_loc5_ < _loc9_)
  456.       {
  457.          _loc4_ = _loc8_[_loc5_];
  458.          if(_loc4_ != null)
  459.          {
  460.             if(_loc4_.grabbable == true)
  461.             {
  462.                if(_loc4_.checkHit(this))
  463.                {
  464.                   _loc4_.react(this);
  465.                }
  466.             }
  467.          }
  468.          _loc5_ = _loc5_ + 1;
  469.       }
  470.       if(m.y > this.halfR)
  471.       {
  472.          m.y = this.halfR;
  473.       }
  474.       this.tempM = null;
  475.       var _loc13_ = this.checkCollisions(nElapsed,_loc10_,_loc12_,false);
  476.       var m = this.tempM;
  477.       var _loc15_ = new smashing.Point(this.x,this.y);
  478.       var _loc14_ = BuildingHandler.floor - this.floorMod;
  479.       if(this.y + m.y > _loc14_)
  480.       {
  481.          this.y = _loc14_;
  482.          this.ym = 0;
  483.          this.jumpm = 0;
  484.          m.y = 0;
  485.          this.onSurface = true;
  486.          _loc13_ = true;
  487.          if(_loc12_ == true)
  488.          {
  489.             _loc6_ = "crouch";
  490.          }
  491.       }
  492.       if(_loc13_ == false)
  493.       {
  494.          if(this.ym > 0)
  495.          {
  496.             _loc6_ = "jumpDown";
  497.          }
  498.          else
  499.          {
  500.             _loc6_ = "jumpUp";
  501.          }
  502.       }
  503.       var _loc11_ = smashing.Viewport.halfWidth - this.r;
  504.       if(this.x + m.x - smashing.Viewport.x < - _loc11_)
  505.       {
  506.          this.x = smashing.Viewport.x - _loc11_;
  507.          m.x = 0;
  508.          this.xm = 0;
  509.       }
  510.       if(this.x + m.x - smashing.Viewport.x > _loc11_)
  511.       {
  512.          this.x = smashing.Viewport.x + _loc11_;
  513.          m.x = 0;
  514.          this.xm = 0;
  515.       }
  516.       this.y += m.y;
  517.       this.x += m.x;
  518.       if(this.bHurt == true)
  519.       {
  520.          if(this.cHurt < this.nHurtTime / 2)
  521.          {
  522.             _loc6_ = "hit";
  523.          }
  524.       }
  525.       _root.nDebug1 = this.cIdle;
  526.       this.cIdle += nElapsed;
  527.       if(this.cIdle >= this.nIdle)
  528.       {
  529.          this.cIdle = 0;
  530.          _global.oSound.playSnd("time_out_use_keys");
  531.       }
  532.       this.a.gotoAndStop(_loc6_);
  533.       if(this.nSpeed == 1)
  534.       {
  535.          this.a.blur._visible = true;
  536.       }
  537.       else
  538.       {
  539.          this.a.blur._visible = false;
  540.       }
  541.    }
  542.    function updateHangPost(nElapsed)
  543.    {
  544.       this.a.gotoAndStop("hangLand");
  545.    }
  546.    function updateSwing(nElapsed)
  547.    {
  548.       var _loc9_ = this.oSwing.hitLength * this.oSwing.hitLength / this.oSwing.pCurrLength.dot(this.oSwing.pCurrLength);
  549.       var _loc5_ = this.oSwing.pCurrLength.multiply(_loc9_);
  550.       _loc5_.x += this.oSwing.x;
  551.       _loc5_.y += this.oSwing.y;
  552.       this.x = _loc5_.x;
  553.       this.y = _loc5_.y;
  554.       var _loc7_ = false;
  555.       if(Key.isDown(32) || Key.isDown(38))
  556.       {
  557.          if(this.bSpaceDown == false)
  558.          {
  559.             _loc7_ = true;
  560.             this.xm = (_loc5_.x - this.lastPos.x) / nElapsed * 2;
  561.             this.ym = (_loc5_.y - this.lastPos.y) / nElapsed * 2;
  562.             this.oSwing.cDisable = 0;
  563.             this.oSwing.bSwung = false;
  564.             this.update = this.updateGround;
  565.          }
  566.       }
  567.       else
  568.       {
  569.          this.lastPos = _loc5_;
  570.          this.lastElapsed = nElapsed;
  571.          this.bSpaceDown = false;
  572.       }
  573.       if(this.bHurt == false)
  574.       {
  575.          var _loc4_ = this.oCitizens.oHandler.clips;
  576.          var _loc8_ = _loc4_.length;
  577.          var _loc2_ = undefined;
  578.          var _loc3_ = 0;
  579.          while(_loc3_ < _loc8_)
  580.          {
  581.             _loc2_ = _loc4_[_loc3_];
  582.             if(_loc2_ != null)
  583.             {
  584.                if(_loc2_.bDead == false)
  585.                {
  586.                   if(_loc2_.collisionTest(this) == true)
  587.                   {
  588.                      if(_loc7_ == false)
  589.                      {
  590.                         this.oSwing.cDisable = 0;
  591.                         this.oSwing.bSwung = false;
  592.                         this.update = this.updateGround;
  593.                      }
  594.                      _loc2_.react(this,nElapsed);
  595.                   }
  596.                }
  597.             }
  598.             _loc3_ = _loc3_ + 1;
  599.          }
  600.       }
  601.       this.a.gotoAndStop("vine");
  602.    }
  603.    function checkCollisions(nElapsed, nXm, bCrouch, bHang)
  604.    {
  605.       if(this.bHurt == false)
  606.       {
  607.          var _loc11_ = this.oCitizens.oHandler.clips;
  608.          var _loc12_ = _loc11_.length;
  609.          var _loc5_ = undefined;
  610.          var _loc8_ = 0;
  611.          while(_loc8_ < _loc12_)
  612.          {
  613.             _loc5_ = _loc11_[_loc8_];
  614.             if(_loc5_ != null)
  615.             {
  616.                if(_loc5_.bDead == false)
  617.                {
  618.                   if(_loc5_.collisionTest(this) == true)
  619.                   {
  620.                      _loc5_.react(this,nElapsed);
  621.                   }
  622.                }
  623.             }
  624.             _loc8_ = _loc8_ + 1;
  625.          }
  626.       }
  627.       this.xm -= smashing.Phys.drag(this.xm,nElapsed);
  628.       if(this.xm > -20)
  629.       {
  630.          this.xm = 0;
  631.       }
  632.       nXm += this.xm * nElapsed;
  633.       var _loc18_ = (this.ym + this.jumpm) * nElapsed;
  634.       this.shadow._x = this._x + nXm;
  635.       this.shadow._y = this._y + _loc18_;
  636.       var _loc6_ = new smashing.Point(nXm,_loc18_);
  637.       var _loc9_ = new smashing.Point(this.x,this.y);
  638.       _loc11_ = this.oBuildings.oHandler.clips;
  639.       _loc12_ = _loc11_.length;
  640.       var _loc10_ = undefined;
  641.       var _loc4_ = undefined;
  642.       var _loc22_ = [];
  643.       var _loc2_ = undefined;
  644.       var _loc7_ = null;
  645.       var _loc13_ = [];
  646.       if(bHang != true)
  647.       {
  648.          _loc8_ = 0;
  649.          while(_loc8_ < _loc12_)
  650.          {
  651.             _loc5_ = _loc11_[_loc8_];
  652.             if(_loc5_.hasObstacle == true)
  653.             {
  654.                if(_loc5_.hitTest(this) == true || _loc5_.hitTest(this.shadow) == true)
  655.                {
  656.                   _loc4_ = _loc5_.aLines;
  657.                   _loc10_ = _loc4_.length;
  658.                   var _loc3_ = 0;
  659.                   while(_loc3_ < _loc10_)
  660.                   {
  661.                      if(bCrouch == false)
  662.                      {
  663.                         if(_loc6_.y > 20)
  664.                         {
  665.                            _loc2_ = _loc4_[_loc3_].collisionPointSwept(_loc9_,_loc6_,this.r);
  666.                         }
  667.                         else
  668.                         {
  669.                            _loc2_ = _loc4_[_loc3_].collisionPointThresh(_loc9_,_loc6_,this.r);
  670.                         }
  671.                      }
  672.                      else if(!smashing.Misc.isHoriz(_loc4_[_loc3_]))
  673.                      {
  674.                         _loc2_ = _loc4_[_loc3_].collisionPointThresh(_loc9_,_loc6_,this.r);
  675.                      }
  676.                      _loc13_.push(_loc2_);
  677.                      if(_loc7_ == null && _loc2_ != null)
  678.                      {
  679.                         _loc7_ = _loc2_;
  680.                      }
  681.                      else if(_loc2_.distSqu < _loc7_.distSqu && _loc2_ != null)
  682.                      {
  683.                         _loc7_ = _loc2_;
  684.                      }
  685.                      _loc3_ = _loc3_ + 1;
  686.                   }
  687.                }
  688.             }
  689.             _loc8_ = _loc8_ + 1;
  690.          }
  691.       }
  692.       var _loc17_ = false;
  693.       if(_loc7_ != null)
  694.       {
  695.          var _loc20_ = Math.sqrt(_loc7_.distSqu);
  696.          _loc6_.length -= _loc20_;
  697.          var _loc19_ = _loc7_.gizmo.lineNormal;
  698.          this.onSurface = true;
  699.          _loc17_ = true;
  700.          var _loc16_ = new smashing.Point(_loc7_.hit.x,_loc7_.hit.y);
  701.          this.x = _loc16_.x;
  702.          this.y = _loc16_.y;
  703.          _loc9_ = new smashing.Point(this.x,this.y);
  704.          _loc6_ = _loc19_.multiply(_loc6_.dot(_loc19_));
  705.          if(_loc6_.y == 0)
  706.          {
  707.             this.ym = 0;
  708.             this.jumpm = 0;
  709.          }
  710.          if(_loc6_.x == 0)
  711.          {
  712.             this.xm = 0;
  713.          }
  714.       }
  715.       else
  716.       {
  717.          this.onSurface = false;
  718.       }
  719.       this.tempM = _loc6_;
  720.       return _loc17_;
  721.    }
  722.    function setBuilding(o, c, g)
  723.    {
  724.       this.oBuildings = o;
  725.       this.oCitizens = c;
  726.       this.oGerms = g;
  727.    }
  728.    function setShadow(mc)
  729.    {
  730.       this.shadow = mc;
  731.       this.shadow._width = this.r * 2;
  732.       this.shadow._height = this.r * 2;
  733.    }
  734.    function render()
  735.    {
  736.       var _loc2_ = smashing.Viewport.getPos(this);
  737.       this._x = _loc2_.x + smashing.Viewport.centerX;
  738.       this._y = _loc2_.y + smashing.Viewport.centerY;
  739.    }
  740.    function hurt()
  741.    {
  742.       _global.oSound.playSnd("upon_hit",40);
  743.       var _loc3_ = new smashing.Point(-3,-2);
  744.       _loc3_.length = 700;
  745.       this.xm = _loc3_.x;
  746.       this.ym = _loc3_.y;
  747.       this.bHurt = true;
  748.       this.nStartHurt = getTimer();
  749.       this.onEnterFrame = function()
  750.       {
  751.          this.cHurt = (getTimer() - this.nStartHurt) / 1000;
  752.          if(this.cHurt >= this.nHurtTime)
  753.          {
  754.             this._visible = true;
  755.             this.bHurt = false;
  756.             delete this.onEnterFrame;
  757.          }
  758.       };
  759.    }
  760.    function invulnerable()
  761.    {
  762.       this.bInvul = true;
  763.       this.mcInvul._visible = true;
  764.    }
  765.    function unInvulnerable()
  766.    {
  767.       this.bInvul = false;
  768.       this.cInvul = 0;
  769.       this.mcInvul._visible = false;
  770.    }
  771.    function speed()
  772.    {
  773.       this.nSpeed = 1;
  774.       this.cSpeedTime = 0;
  775.       _global.oSound.playSnd(smashing.Misc.rndElement(this.fruitSounds));
  776.       _global.oSound.playSnd("bonus_speed",60);
  777.    }
  778.    function unSpeed()
  779.    {
  780.       this.nSpeed = 0;
  781.    }
  782.    function getGerm(g)
  783.    {
  784.       this.aCritters.push(g.sCrit);
  785.       _global.mcRoot.mcMenu.setCritters(this.aCritters);
  786.       this.cGerms = this.cGerms + 1;
  787.       DiegoWorld.addScore(this.germScore);
  788.       _global.mcRoot.oBase.pause();
  789.       this.camera._visible = true;
  790.       this.camera.sCritter = g.sCrit;
  791.       this.camera.mcCritter = g;
  792.       this.a.a.stop();
  793.       this.a.blur.stop();
  794.       this.camera.play();
  795.    }
  796.    function removeGerm()
  797.    {
  798.       this.cGerms = this.cGerms - 1;
  799.       if(this.cGerms < 0)
  800.       {
  801.          this.cGerms = 0;
  802.       }
  803.    }
  804.    function reset()
  805.    {
  806.       this.aCritters = [];
  807.       this.a.gotoAndStop("stand");
  808.       this.x = smashing.Viewport.x - this.oWorld.playerOffset;
  809.       this.y = BuildingHandler.floor - this.r * 3;
  810.       this.cGerms = 0;
  811.       this.bHurt = false;
  812.       delete this.onEnterFrame;
  813.       this._visible = true;
  814.       this.xm = 0;
  815.       this.ym = 0;
  816.       this.jumpm = 0;
  817.       this.nSpeed = 0;
  818.       this.update = this.updateGround;
  819.       this.a.gotoAndStop("stand");
  820.       this.faceRight();
  821.       this.render();
  822.    }
  823.    function faceLeft()
  824.    {
  825.       this.gotoAndStop("left");
  826.       this.facing = -1;
  827.    }
  828.    function faceRight()
  829.    {
  830.       this.gotoAndStop("right");
  831.       this.facing = 1;
  832.    }
  833.    function hang()
  834.    {
  835.       _global.oSound.playSnd("rescupack_pickup");
  836.       _global.oSound.playSnd(smashing.Misc.rndElement(this.hangSounds));
  837.       this.update = this.updateHangPre;
  838.       this.xm = 0;
  839.       this.ym = 0;
  840.       this.cHang = 0;
  841.    }
  842.    function unHang()
  843.    {
  844.       this.a.gotoAndStop("hangLand");
  845.       this.update = this.updateHangPost;
  846.    }
  847.    function swing(o)
  848.    {
  849.       this.oSwing = o;
  850.       this.update = this.updateSwing;
  851.    }
  852.    function addScore(n)
  853.    {
  854.       _global.oSound.playSnd("bonus_coin",60);
  855.       _global.oSound.playSnd(smashing.Misc.rndElement(this.pointSounds));
  856.       this.oWorld.score += n;
  857.    }
  858. }
  859.